from Globals import *
import re
def run():
	pass
	# BroadCastPlugin()

class BroadCastPlugin():
	def __init__(self):
		self.clients = []
		hook.registerHook('server_init', self.addClientToList)
		hook.registerHook('unhandledCommand_before', self.command)

	def addClientToList(self, args):
		self.clients.append(args['clientsocket'])

	def command(self, args):
		if re.match("^broadcast", args['data']):
			message = args['data'].split('broadcast ')
			for client in self.clients:
				client.send("\nBroadcasted message from " + args['clientsocket'].getpeername()[0] + ": " + message[1])
